package com.kgar.controller;

import com.kgar.dto.Result;
import com.kgar.entity.pojo.Resume;
import com.kgar.service.ResumeService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;

/**
 * @author Trimb
 */
@RestController
@RequestMapping("/resume")
public class ResumeController {

    @Resource
    private ResumeService resumeService;

    @PostMapping("queryAll")
    public Result queryAll() {
        return resumeService.queryAll();
    }

    @PostMapping("query")
    public Result query() {
        return resumeService.queryByUserId();
    }

    /**
     * 保存简历草稿
     *
     */
    @PostMapping("saveDraft")
    public Result saveDraft(@RequestBody Resume resume) {
        return resumeService.saveDraft(resume);
    }

    @PostMapping("parse")
    public Result parseResume(@RequestParam("file") MultipartFile file) {
        return resumeService.parseResumeV2(file);
    }

    @PutMapping("update")
    public Result updateResume(@RequestBody Resume resume) {
        return resumeService.updateResume(resume);
    }

    @DeleteMapping("delete")
    public Result deleteResume(@RequestParam("resumeId") Integer resumeId) {
        return resumeService.deleteById(resumeId);
    }

}
